import time
import cv2
import numpy
from PyQt5.QtWidgets import QGraphicsPixmapItem
from PyQt5.QtGui import QImage
from queue import Queue


class Debuger:

    def __init__(self, initMaxSize=50, timeSwitch=False, debugName='System', timeFormat='%H:%M:%S'):
        self.initMaxSize = initMaxSize
        self.debugName = debugName
        self.timeFormat = timeFormat
        self.__timeSwitch = timeSwitch
        self.__Q = Queue(maxsize=initMaxSize)

    def pushInfo(self, strs, status='Debug'):
        if not self.__timeSwitch:
            infoText = '[{}-{}]--> {}'.format(self.debugName, status, strs)
        else:
            infoText = '[{}-{}-{}]--> {}'.format(self.debugName,
                                                 time.strftime(self.timeFormat, time.localtime(time.time())),
                                                 status, strs)
        if not self.__Q.full():
            self.__Q.put(infoText)
            print(infoText)
        else:
            self.__Q.get()
            self.__Q.put(infoText)
            print(infoText)

    def getInfo(self):
        if not self.__Q.empty():
            res = self.__Q.get()
            return res
        else:
            return None


class ImageBox:
    """
    描述：图像盒子
    功能：存储一系列图像的信息
    参数：名字， 路径， 大小， OpenCV图像， QImage图像
    场景元素图像， 标签字典
    返回值：
    """
    def __init__(self, name: str, path: str, size: str,
                 ImageCv2: numpy.ndarray, ImageQt: QImage,
                 ImageGraph: QGraphicsPixmapItem, LabelBox: dict):
        self.name = name
        self.path = path
        self.size = size
        self.ImageCv2 = ImageCv2
        self.ImageQt = ImageQt
        self.ImageGraph = ImageGraph
        self.LabelBox = LabelBox


if __name__ == '__main__':
    frame = cv2.imread('/home/cy/图片/QtLogo.jpg')
    print(type(frame))